package com.zhang.spark_2.com.zhang.core.transform

import org.apache.spark.{SparkConf, SparkContext}

/**
 * @title:
 * @author: zhang
 * @date: 2022/2/12 16:29 
 */
object Spark05_filter {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local[*]").setAppName("map")
    val sc = new SparkContext(conf)

    sc
      .textFile("data/apache.log")
      .filter(
        line=>{
          val datas: Array[String] = line.split(" ")
          datas(3).startsWith("17/05/2015")
        }
      )
      .map(
        line=>{
          val datas: Array[String] = line.split(" ")
          datas(6)
        }
      )
      .collect()
      .foreach(println)

    sc.stop()
  }

}
